import {BattleInfo_FinalBattleInfo, FreshImmortal, GrowthRecord} from "db://assets/proto/shared/v1/wuni";
import {FishStatus} from "db://assets/proto/shared/v1/biz";

export namespace fishUtils {

    export function maxNormalHealth(battleInfo: BattleInfo_FinalBattleInfo): number {
        return battleInfo.normalHealth.mul(battleInfo.normalHealthBonus.add(10000)).div(10000).toNumber();
    }

    export function maxMagicPower(battleInfo: BattleInfo_FinalBattleInfo): number {
        return battleInfo.magicPower.mul(battleInfo.magicPowerBonus.add(10000)).div(10000).toNumber();
    }

    export function calcGrowthRequireMoney(currentLevel: number): number {
        const exponent = Math.floor(currentLevel / 10);
        return 800 * Math.pow(currentLevel, 3) * Math.pow(1.65, exponent);
    }

    export function processGrowthValue(ff: FreshImmortal, record: GrowthRecord) {
        ff.battleInfo!.growthRecords.push(record)
    }

    const aliveFishStatus: FishStatus[] = [
        FishStatus.alive,
        FishStatus.pre_battle,
        FishStatus.in_battle,
        FishStatus.moving,
    ]

    export function checkFishAlive(status: FishStatus): boolean {
        return aliveFishStatus.indexOf(status) !== -1
    }
}